package test;

import GameLogic.*;
import OGLRenderer.GL_Renderer;
import org.lwjgl.opengl.Display;
import Input.BasicInput;

import java.util.ArrayList;


public class OGL_call {
    public static void main(String[] aa){
        EntityCoordinate coord;
        EntityModel mod = new EntityModel();
        mod.frames=1;                            //model does not have any frames
        mod.texture_coordinates=new float[] {0.0f, 0.0f,      //quad vertices; NOTICE: if you start with 0 as bottom left vertex
                                     0.0f, 1.0f,       // it will spin around this vertex (rotate is performed on 0,0)
                                     1.0f, 1.0f,
                                     1.0f, 0.0f};
        mod.texture_path="src/test/demo_tex";           //nor texture
        mod.vertex_colour = new float[] {0.0f, 0.0f, 0.0f, 1.0f,  //RGBA, each vertex of quad
                                        0.0f, 0.0f, 0.0f, 1.0f,
                                        0.0f, 0.0f, 0.0f, 1.0f,
                                        0.0f, 0.0f, 0.0f, 1.0f};
         mod.vertices = new float[] {-0.125f, -0.125f,      //quad vertices; NOTICE: if you start with 0 as bottom left vertex
                                     0.125f, -0.125f,       // it will spin around this vertex (rotate is performed on 0,0)
                                     0.125f, 0.125f,
                                     -0.125f, 0.125f};
        EntityModel mod2 = new EntityModel(); //second model
        mod2.frames=0;
        mod2.texture_coordinates=null;
        mod2.texture_path=null;
        mod2.vertex_colour = new float[] {1.0f, 0.0f, 0.0f, 0.0f,
                                        0.0f, 1.0f, 0.0f, 0.7f,
                                        0.0f, 0.0f, 1.0f, 0.4f,
                                        0.0f, 0.0f, 1.0f, 1.0f};
         mod2.vertices = new float[] {0.0f, 0.0f,
                                     0.25f, 0.0f,
                                     0.25f, 0.25f,
                                     0.0f, 0.25f};

        GL_Renderer ekran = new GL_Renderer("TITLE", 1000, 600, false);   //initialize screen
        coord = new EntityCoordinate(0.0, 0.0,-0.5, 0.0f, 1.0f, 1.0f, ekran.LoadObject(mod)); //load object with initial coordinates(notice last argument with ID)
        ArrayList<EntityCoordinate> aaa = new ArrayList<EntityCoordinate>();
        aaa.add(coord);                                      //it's time to put out coordinates with assigned ID
        EntityCoordinate co2 = new EntityCoordinate(-0.3, -0.6, 0.0, 0.0f, 1.0f, 1.0f,ekran.LoadObject(mod2)); //second model
        aaa.add(co2);
        aaa.add(new EntityCoordinate(-0.7, 0.5,0.5, 0.0f, 1.0f, 1.0f,  aaa.get(0).modelID)); //first model but other coordinates = another instance of first model

        BasicInput bi = new BasicInput(); //init input
        int a = bi.update();
        double tmp = 0;
        double tmp2 = 0;
        float tmp3 =0;
        while (!Display.isCloseRequested()) {
             ekran.DrawFrame(aaa, 0.0, 0.0);
            a = bi.update();
            switch (a){
                case 1 : tmp = -0.01 ; break;

                case 2 : tmp = 0.01; break;

                case 3 : tmp2 = -0.01; break;
                case 4 : tmp2 = 0.01; break;

                case 5 : ekran.ChangeProjection(); break;

                case 11 : tmp = 0; break;
                case 12 : tmp = 0; break;

                case 13 : tmp2 = 0; break;
                case 14 : tmp2 = 0; break;

                //case 15 : tmp3 = 0;




            }
             aaa.get(0).posY+= tmp;  //values are passed as reverences, so we can apply changes directly
             aaa.get(0).posX+= tmp2;
             aaa.get(1).posX+= tmp2;
             aaa.get(1).posY+= tmp;
            aaa.get(2).posX-= tmp2;
            aaa.get(2).posY-= tmp;
            aaa.get(1).angle +=0.1f;
            if (aaa.get(1).angle > 360.0f)
                aaa.get(1).angle = 0.0f;
            aaa.get(2).angle+=0.4f;
            if (aaa.get(2).angle > 360.0f)
                aaa.get(2).angle = 0.0f;

        }


    }
}
